import pandas as pd

# 读取警情字典Excel
df = pd.read_excel('H://dict.xlsx')

# 构建知识库专用格式
if "盗窃" in df['警情类型名称'] or "扒窃" in df['警情类型名称']:
    df['knowledge_snippet'] = "【警情类型】" + df['警情类型名称'] + "\n" + \
                              "【判定标准】" + df['警情类型判定标准'] + "\n" + \
                              "【唯一标识】" + df['警情类型名称'].apply(lambda x: f"ID_{hash(x)}") + "\r\n"

# 保存为Dify可导入格式
df[['knowledge_snippet']].to_csv('police_knowledge.csv', index=False)